

// store/reducer.js
import {
  ADD_NUMBER,
  SUB_NUMBER,
} from './constants.js'

// counterReducer
const inintStateCounter = {
  counter: 0,
}
export default function counterReducer(state = inintStateCounter, action){
  switch(action.type){
    case ADD_NUMBER:
      return {...state, counter: state.counter + action.num}
    case SUB_NUMBER:
      return {...state, counter: state.counter - action.num}
    default:
      return state
  }
}
